home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj0687.arc / ASKKEY.ASM < prev    next >
Assembly Source File  |  1987-04-21  |  2KB  |  33 lines

  1. ; ASKKEY - Display text and accept a char from Standard Input.
  2. ;          Return the ASCII code of the char as an ERRORLEVEL.
  3. Code          Segment
  4.               Org       0100H
  5.               Assume    CS:Code, DS:Code
  6. AskKey        Proc      Far
  7. Begin:        Mov       SI,81H          ; SI -> 1st cmd line char
  8. ; Display all text in the command line up to 0DH (Carridge Return)
  9. NxtChar:      Mov       DL,[SI]         ; get char from command line
  10.               Cmp       DL,0DH          ; CR char means end of string
  11.               Je        GetChar         ; Goto input mode if at end
  12.               Mov       AH,02H          ; Standard Output function
  13.               Int       21H             ; call DOS to output char
  14.               Inc       SI              ; increment to next char
  15.               Jmp       NxtChar         ; and go get it
  16. ; Accept a single character response from Standard Input
  17. GetChar:      Mov       AH,01H          ; Standard Input function
  18.               Int       21H             ; Call DOS, get char into AL
  19.               Cmp       AL,0            ; extended character?
  20.               Je        GetChar         ; Yes, get the scan code
  21.               Cmp       AL,'a'          ; is char less than 'a' ?
  22.               Jb        Xit             ; Yes, skip case change
  23.               Cmp       AL,'z'          ; is it greater than 'z' ?
  24.               Ja        Xit             ; Yes, bypass case change
  25.               And       AL,NOT 20H      ; change to upper case
  26. ; Return to DOS with the RETCODE set
  27. Xit:          Mov       AH,4CH          ; Set exit function
  28.               Int       21H             ; call DOS to leave
  29.                                         ; AL already has RETCODE
  30. AskKey        Endp
  31. Code          Ends
  32.               End           Begin
  33.